<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="app">
        <input type="text" name="" id="" @keyup.enter="add" v-model="msg">
        <ul>
            <li v-for="(item,index) in arr">{{index+1}}{{item}}<button @click="remove(index)">删除</button></li>
        </ul>
    </div>
    <script src="../vue.js"></script>
    <script>
        const vm = new Vue({
            el: ".app",
            data: {
                arr: ["好好学习", "天天向上"],
                msg: "你好"
            },
            methods: {
                add() {
                    this.arr.push(this.msg)
                    this.msg = ""
                },
                remove(index) {
                    console.log(index);
                    this.arr.splice(index, 1)
                }
            }
        })
    </script>
</body>

</html>